
package lc.dbUnit;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class LcUnit {

	public static Date convertToDate15(String t) {
		if (t == null) {
			return null;
		}
		if (t.length() != 15) {
			return null;
		}
		int year = Integer.parseInt(t.substring(0, 4));
		int month = Integer.parseInt(t.substring(4, 6)) - 1;
		int day = Integer.parseInt(t.substring(6, 8));
		int h = Integer.parseInt(t.substring(8, 10));
		int m = Integer.parseInt(t.substring(10, 12));
		int s = Integer.parseInt(t.substring(12, 14));
		//int ss = Integer.parseInt(t.substring(14));

		Calendar d = Calendar.getInstance();
		d.set(year, month, day, h, m, s);

		return d.getTime();
	}

	private static SimpleDateFormat	Time15Format	= new SimpleDateFormat("yyyyMMddHHmmss");

	public static String convertDataTo15(Date date) {
		synchronized (Time15Format) {
			if (date == null) {
				return "";
			}
			return Time15Format.format(date) + "0";
		}
	}

	public static String convertDataTo15(long date) {
		return convertDataTo15(new Date(date));
	}
	
	public static String lcSexConvert(String sex) {
		if ("W".equals(sex)) {
			return "2";
		} else if ("M".equals(sex)) {
			return "1";
		}
		return null;
	}
	
	public static String lcSexConvert1(String sex) {
		if ("1".equals(sex)) {
			return "2";
		} else if ("0".equals(sex)) {
			return "1";
		}
		return null;
	}
}
